package com.bjpowernode.springboot.web;


import com.bjpowernode.springboot.domain.Character;
import com.bjpowernode.springboot.service.CharacterService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/character")
public class CharacterController {
    @Autowired
    CharacterService characterService;
    @ApiOperation(value = "根据ID查询")
    @GetMapping("/get")
    public Character getCharacterById(@RequestParam int id){
        return characterService.selectByPrimaryKeyCharacter(id);
    }
    @ApiOperation(value = "新增")
    @PostMapping("/save")
    public int insertCharacter(@RequestBody Character record){
        return this.characterService.insertCharacter(record);
    }
    @ApiOperation(value = "删除")
    @PatchMapping("/delete")
    public int deleteCharacter(@RequestParam int id) {
        return this.characterService.deleteByPrimaryKeyCharacter(id);
    }
    @ApiOperation(value = "修改")
    @PutMapping("/update")
    public int updateCharacter(@RequestParam Character record) {
        return this.characterService.updateByPrimaryKeySelectiveCharacter(record);
    }

    public ArrayList<Character> goods=new ArrayList<>();
    @GetMapping ("/pagehelper")
    @ResponseBody
    public List<Character> pageHelperController(int page, int size) {

        return characterService.selectDaoCharacter(page, size);
    }

    @GetMapping ("/sel")
    public List<Character> selectDaoCharacterQ(){
        return characterService.selectDaoCharacterQ();
    }
}
